using System.Data;
using DataSync.DataAccess.Staff;
using DataTable=System.Data.DataTable;

namespace DataSync.Services.Staff
{
    public class StaffService
    {
        private readonly StaffDataAccess _StaffDataAccess;

        public StaffService()
        {
            _StaffDataAccess = new StaffDataAccess();
        }

        public DataTable GetStaffs()
        {
            return _StaffDataAccess.GetStaffs();
        }

        public DataTable GetStaffs(int departmentId)
        {
            return _StaffDataAccess.GetStaffs(departmentId);
        }

        public bool InsertStaff(DataTable dataTable, int serverIdentification)
        {
            if (dataTable == null)
                return false;

            foreach (DataRow dataRow in dataTable.Rows)
            {
                if(dataRow == null)
                    continue;

                if (!_StaffDataAccess.InsertStaff(dataRow, serverIdentification))
                    return false;
            }
            return true;
        }

        public bool DeleteStaffs(int serverIdentification)
        {
            return _StaffDataAccess.DeleteStaffs(serverIdentification);
        }
    }
}